#!/usr/bin/env node

const http = require('http');

http.createServer((req, res) =>{
  let html = `<!DOCTYPE html>
  <html lang="en">
  <head>
    <meta charset="UTF-8">
    <title>login</title>
    </head>
    <body>
      英文感叹号，ctrl+y，松手，按逗号
      <form action="">
        <lable>username:</lable>
        <input type="text" name="username">
        <br>
        <lable>password:</lable>
        <input type="password" calue="login">
        <br>
        <input type="button" value="login">
      </form>
    </body>
  </html>`;

  if(req.url === '/') {
    res.writeHead(200, {
      'Content-Type': 'text/html',
      'Content-Lenght': Buffer.byteLength(html)        
    });
    res.end(html);
  } else {
    res.statusCode = 404;
    res.setHeader('Content-Type', 'text/plain');
    res.end('Resource not found!');            
  }                     
}).listen(8080);
